package com.atguigu.jinx.enums.alipay;

import lombok.Getter;

/**
 * Author:VEGA_KUANGQI
 * <p>
 * 2025/8/31
 */

@Getter
public enum AlipayTradeStatus {

    WAIT_BUYER_PAY("WAIT_BUYER_PAY", "交易创建，等待买家付款"),
    TRADE_CLOSED("TRADE_CLOSED", "未付款交易超时关闭，或支付完成后全额退款"),
    TRADE_SUCCESS("TRADE_SUCCESS", "交易支付成功"),
    TRADE_FINISHED("TRADE_FINISHED", "交易结束，不可退款");

    private final String code;
    private final String description;

    AlipayTradeStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }


    /**
     * 根据 code 获取枚举
     */
    public static AlipayTradeStatus fromCode(String code) {
        for (AlipayTradeStatus status : values()) {
            if (status.code.equals(code)) {
                return status;
            }
        }
        return null; // 或者抛异常，根据你的业务需求
    }
}
